using System.Web.Security;
using Castle.MonoRail.Framework;
using WineCellar.Web.Common;

namespace WineCellar.Web
{
    public abstract class MembershipMailPropertyAccessor
    {
        private Controller _controller;
        public class Fields
        {
		    public const string To= "to";
		    public const string From= "from";
		    public const string System= "system";
		    public const string Name= "name";
		    public const string Signature= "signature";
		    public const string ReplyEmail= "replyemail";
        }
        public MembershipMailPropertyAccessor(Controller controller, MembershipUser user)
        {
            this._controller = controller;
            this.To = user.Email;
            this.Name = user.UserName;

            MembershipManagerSection membershipManagerSection = MembershipManagerSection.GetConfig();
            this.From = membershipManagerSection.Email.From;
            this.System = membershipManagerSection.Email.System;
            this.Signature = membershipManagerSection.Email.Signature;
            this.ReplyEmail = membershipManagerSection.Email.ReplyEmail;
        }
        protected Controller Controller
        {
            get { return this._controller; }
        }
        public string To
        {
            get { return (string) this._controller.PropertyBag[Fields.To]; }
            set { this._controller.PropertyBag[Fields.To] = value; }
        }
        public string From
        {
            get { return (string)this._controller.PropertyBag[Fields.From]; }
            set { this._controller.PropertyBag[Fields.From] = value; }
        }
        public string System
        {
            get { return (string)this._controller.PropertyBag[Fields.System]; }
            set { this._controller.PropertyBag[Fields.System] = value; }
        }
        public string Name
        {
            get { return (string)this._controller.PropertyBag[Fields.Name]; }
            set { this._controller.PropertyBag[Fields.Name] = value; }
        }
        public string Signature
        {
            get { return (string)this._controller.PropertyBag[Fields.Signature]; }
            set { this._controller.PropertyBag[Fields.Signature] = value; }
        }
        public string ReplyEmail
        {
            get { return (string)this._controller.PropertyBag[Fields.ReplyEmail]; }
            set { this._controller.PropertyBag[Fields.ReplyEmail] = value; }
        }
    }
}
